<template>
	<view class="">
		<view class="sign-item">
			<view class="sign-item-head">
				<view class="sign-item-head-name">
					{{ signItem.title }}
				</view>
			</view>
			<view class="sign-item-content">
				<view class="sign-item-content-info">
					{{ signItem.content }}
				</view>
			</view>
			<view class="sign-item-footer" v-if="signItem.signParam.signType == 1 || signItem.signParam.signType == 8">
				<!-- <button class="reset-button cancel-btn" v-if="signItem.messageStatus != 2" @click="cancel(signItem)">拒绝签约</button> -->
				<button class="reset-button confirm-btn" @click="confirm(signItem)">去签约</button>
			</view>
			<view class="sign-item-footer" v-if="signItem.signParam.signType == 2 || signItem.signParam.signType == 9">
				<button class="reset-button cancel-btn" v-if="signItem.messageStatus != 2" @click="cancel(signItem)">拒绝授权</button>
				<button class="reset-button confirm-btn" @click="confirm(signItem)">去授权</button>
			</view>
		</view>
		
		<!-- <view class="sign-item">
			<view class="sign-item-head">
				<view class="sign-item-head-name">
					《车辆运输协议》
				</view>
			</view>
			<view class="sign-item-content">
				<view class="sign-item-content-info">
					您的运单pz123456789尚未完成运输协议签订，请及时完成签约
				</view>
			</view>
			<view class="sign-item-footer">
				<button class="reset-button confirm-btn" @click="confirm">去签约</button>
			</view>
		</view> -->
	</view>
</template>

<script>
export default {
	props: {
		item: {
			type: Object,
			default: () => {
				return {}
			}
		}
	},
	computed: {
		signItem() {
			let item = this.item
			item.signParam = JSON.parse(item.signParam)
			return {
				...item
			}
		}
	},
	methods: {
		confirm(item) {
			//#ifdef MP-WEIXIN
			uni.navigateTo({
				url: "/pages/sign/signPreview?isBatch=1" + "&ids=" + item.id
			})
			//#endif
			//#ifdef APP-PLUS
			uni.navigateTo({
				url: "/pages/sign/signPreview?isBatch=1" + "&ids=" + item.id + '&navType=switchTab&navUrl=/pages/index/taskhome' 
			})
			//#endif
		},
		cancel(item) {
			uni.showModal({
				title: "提示",
				content: "是否确认拒绝",
				success: (res)=> {
					if (res.confirm) {
						this.wxRequest({
							url: `${this.API}/driverMessageCertification/driverRefuseSign`,
							method: 'POST',
							data: {
								certificationId: item.id
							},
							title: '加载中...',
							success: res => {
								uni.showToast({
									title: "已拒绝",
									icon: "none"
								})
								this.$emit("statusChange")
							}
						})
					}
				}
			})
			
		}
	}
}
</script>

<style lang="scss" scoped>
	.reset-button {
		padding: 0;
		margin: 0;
		font-size: inherit;
		background-color: transparent;
		color: inherit;
		position: relative;
		border: 0rpx;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		text-align: center;
		text-decoration: none;
		white-space: nowrap;
		vertical-align: baseline;
		transform: translate(0, 0);
	}
	.reset-button.button-hover {
		transform: translate(1px, 1px);
		background: none;
	}
	
	.reset-button::after {
		border: none;
	}
	.sign-item {
		background-color: #fff;
		margin: 20rpx;
		border-radius: 8rpx;
		.sign-item-head {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 30rpx 30rpx 20rpx;
			.sign-item-head-name {
				font-size: 32rpx;
				color: #000;
			}
		}
		.sign-item-content {
			font-size: 28rpx;
			color: #333;
			padding: 10rpx 30rpx;
		}
		.sign-item-footer {
			display: flex;
			align-items: center;
			justify-content: flex-end;
			padding: 0 30rpx 30rpx;
			.cancel-btn {
				padding: 0 30rpx;
				border: 2rpx solid #4089ff;
				color: #4089ff;
				margin-right: 30rpx;
				height: 50rpx;
				line-height: 50rpx;
			}
			.confirm-btn {
				padding: 0 30rpx;
				border: 2rpx solid #4089ff;
				color: #4089ff;
				height: 50rpx;
				line-height: 50rpx;
			}
		}
	}
</style>